// 这里添加规则
// zh:中文，phone手机，email邮箱, idCard身份证验证，无算法验证
// rexType:'phone',
export const refObject = {
	zh: /^[\u4e00-\u9fa5]+$/,//中文
	number: /^[0-9]+$/,//整数
	password: /^(?![0-9]+$)(?![a-zA-Z\.!@#$%^&*()_+|{}?><\-\]\\[\/'"\:\;\,\<\>]+$)[0-9A-Za-z\.!@#$%^&*()_+|{}?><\-\]\\[\/'"\:\;\,\<\>]{6,20}$/,//密码数字加特殊字符
	phone: /^1[3456789]\d{9}$/,// 中国手机号验证
	email: /^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/,// 邮箱验证
	// idCard: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/
}
export const refArr = Object.keys(refObject)



/**
 * 获取某年某月有多少天
 */
export const getOneMonthDays = (year,month)=>{
	month = Number(month);
	const baseMonthsDays = [31,28,31,30,31,30,31,31,30,31,30,31];
	if(year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)){
		if(month === 1){
			baseMonthsDays[month] = 29;
		}
	}
	return baseMonthsDays[month];
}

/**
 * 获取日期的年月日时分秒
 */
export const getTimeArray = (date)=>{
	const year = date.getFullYear();
	const month = date.getMonth()+1;
	const day = date.getDate();
	const hour = date.getHours();
	const minute = date.getMinutes();
	const second = date.getSeconds();
	return [year,month,day,hour,minute,second];
}
/**
 * 小于10的数字前面补0
 */
export const addZero = (num)=>{
	return num < 10 ? '0' + num : num;
}

/**
 * 获取当前值在数组中的索引
 */
export const getIndexOfArray = (value,array)=>{
	let index = array.findIndex(item => item == value);
	return index > -1 ? index : 0;
}
